package com.xzh.mallorderspi.model;


import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xzh.mallorderspi.model.OrderItem;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;


@TableName("`order`")
@Getter
@Setter
public class Order  implements Serializable {
    @ExcelProperty("ID")
    @TableId(type = IdType.AUTO)
    private Integer id;//非业务主键

    @ExcelProperty("订单编号")
    @TableField(condition = SqlCondition.LIKE, whereStrategy = FieldStrategy.NOT_EMPTY)
    private String orderNo;//订单编号，使用雪花算法生成

    @ExcelProperty("秒杀编号")
    private String seckillNo;//秒杀编号，可为null，仅用于秒杀

    @ExcelProperty("会员账号")
    private String memberAccount;//会员账号

    @ExcelProperty("支付总价")
    private BigDecimal totalPay;//支付总价

    @ExcelProperty("支付类型")
    private String payType;//支付类型

    @ExcelProperty("阿里支付交易流水号")
    @TableField(condition = SqlCondition.LIKE, whereStrategy = FieldStrategy.NOT_EMPTY)
    private String alipayTradeNo;//阿里支付交易流水号

    @ExcelProperty("下单时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime checkoutTime;//下单时间

    @ExcelProperty("支付时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime payTime;//支付时间

    @ExcelProperty("发货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime shipTime;//发货时间

    @ExcelProperty("确认收货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime acceptTime;//确认收货时间

    @ExcelProperty("订单状态")
    private String status;//订单状态


    private Integer receiverAddrId;//收货人地址，会员收货地址编号

    //以下3项用于缓存数据，防止地址删除的情况
    @ExcelProperty("收货人姓名")
    @TableField(condition = SqlCondition.LIKE, whereStrategy = FieldStrategy.NOT_EMPTY)
    private String receiverName;//收货人姓名

    @ExcelProperty("收货人手机号")
    @TableField(condition = SqlCondition.LIKE, whereStrategy = FieldStrategy.NOT_EMPTY)
    private String receiverPhone;//收货人手机号

    @ExcelProperty("收货人地址详情")
    @TableField(condition = SqlCondition.LIKE, whereStrategy = FieldStrategy.NOT_EMPTY)
    private String receiverAddrDetail;//收货人地址详情

    @ExcelProperty("订单备注")
    private String orderComment;//订单备注

    @ExcelProperty("是否逻辑删除")
    private Boolean isDel;//是否逻辑删除

    @ExcelProperty("备注")
    private String description;//备注

    @TableField("created_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;


    @ExcelIgnore
    @TableField(exist = false)
    private List<OrderItem> orderItems;//订单项

}
